package com.linkgie.galaxyframework.utils;

import java.util.Iterator;
import java.util.Objects;
import java.util.function.IntConsumer;

/**
 * int 基本类型的迭代器；<p>
 * 
 * 采用了与 jdk 标准迭代器 {@link Iterator} 一致的语义规范；
 * 
 * @author spring
 *
 */
public interface IntIterator {

    boolean hasNext();

    int next();

    
    default void remove() {
        throw new UnsupportedOperationException("remove");
    }

    default void forEachRemaining(IntConsumer action) {
        Objects.requireNonNull(action);
        while (hasNext())
            action.accept(next());
    }
}
